package me.samlss.lighter.shape;

import ohos.agp.render.Paint;
import ohos.agp.render.Path;
import ohos.agp.utils.RectFloat;

/**
 * @author: zhu_zhonglin
 * @time: 2021/4/25
 */
public class RectShape extends LighterShape {
    private float mXRadius;
    private float mYRadius;


    /**
     * Construct a rectangular shape object.
     * <p>
     * Will call {@link #RectShape(float, float, float)} and pass the parameters are (5, 5, 15);
     */
    public RectShape() {
        this(5, 5, 15);
    }

    /**
     * Construct a rectangular shape object.
     *
     * @param rx         The x-radius of the oval used to round the corners
     * @param ry         The y-radius of the oval used to round the corners
     * @param blurRadius The radius to extend the blur from the original mask.
     */
    public RectShape(float rx, float ry, float blurRadius) {
        super(blurRadius);
        mXRadius = rx;
        mYRadius = ry;
    }


    @Override
    public void setPaint(Paint paint) {
        this.paint = paint;
    }

    @Override
    public void setViewRect(RectFloat rect) {
        super.setViewRect(rect);

        if (!isViewRectEmpty()) {
            path.reset();
            path.addRoundRect(highlightedViewRect, mXRadius, mYRadius, Path.Direction.CLOCK_WISE);
        }
    }
}
